package l.l.w.携程.题目1;

import java.util.Scanner;

/**
 * Created by llw on 2018/3/29/0029.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for(int i = 0; i < n; ++i){
            nums[i] = scanner.nextInt();
        }
        int j = 0;
        for(int i = 0; i < n; ++i){
            if(nums[i] != 0){
                if(i != j){
                    swap(nums,i,j);
                }
                j++;
            }
        }
        for(;j < n; ++j){
            nums[j] = 0;
        }
        for(int i = 0; i < n; ++i){
            System.out.println(nums[i]);
        }
    }

    private static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}
